<template>
  <div class="define_aside">
    <div class="define_header">
      <i class="el-icon-menu"></i>{{ $t("flowDefine.form.flowType.title") }}
    </div>
    <div class="define_content">
      <el-tree
        :data="treeData"
        @node-click="changeFlowType"
        node-key="id"
        :props="defaultProps"
      >
      </el-tree>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
import { listClassify } from "@/api/flowClassifyApi";
export default {
  name: "define_aside",
  data() {
    return {
      defaultProps: {
        children: "children",
        label: "name",
      },
      treeData: [],
    };
  },
  computed: {
    ...mapState("flowInstance", ["form"]),
  },
  methods: {
    async changeFlowType(item) {
      this.form.flowType = item.id;
      this.$store.dispatch("flowInstance/fetchListRequest");
    },
  },
  mounted() {
    listClassify().then((res) => {
      this.treeData = res.data;
    });
  },
};
</script>

<style lang="scss" scoped>
.define_aside {
  background: #fff;
  padding-right: 10px;
  margin-right: 10px;
  width: 250px;
  overflow: auto;
  .define_header {
    border-bottom: 1px solid #eee;
    height: 40px;
    width: 100%;
    line-height: 40px;
    & i {
      color: #3e70dd;
      padding: 0 5px;
    }
  }
  .define_content {
    overflow: auto;
  }
}
</style>
